#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int countEven(int num) {
        int count = (num / 10) - 1;
        int sum = 0;
        if (count > 0)
            sum = (count * 5);

        for (int i = 2; i < 9 && i <= num; i += 2)
        {
            sum += 1;
        }

        string s1;
        if (num > 10)
        {
            for (int i = num - (num % 10); i <= num; ++i)
            {
                s1 = to_string(i);
                int Add = 0;
                for (int j = 0; j < s1.size(); ++j)
                {
                    Add += s1[j];
                }
                if (Add % 2 == 0)
                    sum++;
            }
        }



        return sum;
    }
};